package com.easemob.chatuidemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.LinearLayout;

import com.easemob.chatuidemo.R;
import com.easemob.chatuidemo.fragment.AboutFragment;
import com.easemob.chatuidemo.fragment.MessageToRemindFragment;
import com.easemob.chatuidemo.fragment.MiscellaneousFunctionFragment;
import com.easemob.chatuidemo.fragment.PrivacyFragment;

/**
 * Created by lanou3g on 15/9/17.
 */
public class SettingsActivity extends FragmentActivity {
    public  static String TAG = "SettingsActivity";

    // 声明
    private LinearLayout linearLayoutSettings;
    private MessageToRemindFragment messageToRemindFragment;
    private MiscellaneousFunctionFragment miscellaneousFunctionFragment;
    private PrivacyFragment privacyFragment;
    private AboutFragment aboutFragment;

    // Fragment类型数组
    private Fragment[] fragments;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 加载布局文件
        setContentView(R.layout.activity_settings);
        init();
    }

    /**
     * 初始化
     **/
    public void init() {
        // 创建意图对象 接收数据
        Intent intent = getIntent();
        // 创建接收数据对象
        int index = intent.getIntExtra("index", 0);

        Log.i(TAG, "index : " + index);

        // 不同数值载入相对应的布局
        switch (index) {
            case 0:
                getSupportFragmentManager().beginTransaction().add(R.id.ll_settings, new MessageToRemindFragment()).commit();
                break;
            case 1:
                getSupportFragmentManager().beginTransaction().add(R.id.ll_settings, new MiscellaneousFunctionFragment()).commit();
                break;
            case 2:
                getSupportFragmentManager().beginTransaction().add(R.id.ll_settings, new PrivacyFragment()).commit();
                break;
            case 3:
                getSupportFragmentManager().beginTransaction().add(R.id.ll_settings, new AboutFragment()).commit();
                break;
        }
    }
}

